package practices;

import java.util.Scanner;

public class CatchException {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入被除数：");
        int dividend = Integer.parseInt(sc.nextLine());
        System.out.println("请输入除数：");
        try {
            int divisor = Integer.parseInt(sc.nextLine());
            System.out.println("商为：" + dividend / divisor);
        }catch (NumberFormatException e) {
            System.out.println("输入的不是整数，请重新输入");
        }catch (ArithmeticException e) {
            System.out.println("除数不能为0，请重新输入");
        }finally {
            sc.close();
        }
    }
}
